<?php
/**
 * Manageaccount_Data_Checkuserdata
 * check user data
 * 
 * @author Adrian Stolarski
 */
class Manageaccount_Data_Checkuserdata implements Manageaccount_Data_Mainable, 
        Manageaccount_Data_Preparable {
    
    /**
     *
     * @var type $data
     * database hamdler
     */
    public $database;
    /**
     *
     * @var type $database_query
     * database query handler
     */
    public $database_query;
    
    /**
     * constructor()
     */
    public function __construct() {
        $this->database = new Core_Driver_MysqlImproved;
    }
    
    /**
     * main()
     * get user data
     * @param array $variables
     * @return type $user_data
     */
    public function main(array $variables = null) {
        $this->database->connect();
        foreach($variables as $key => $value){
            $variables[$key] = $this->database->escape($value);
        }
        //var_dump($variables);
        //die();
        $this->prepare_query($variables);
        $this->database->prepare($this->database_query);
        $this->database->query();
        $user_data = $this->database->fetch('array');
        //var_dump($user_data);
        //die();
        return $user_data;
    }
    
    /**
     * prepare_query()
     * prepare database query
     * 
     * @param array $variables
     */
    public function prepare_query(array $variables = null) {
        $this->database_query = "SELECT * FROM users_data WHERE id='".$variables['user_id']."';";
    }

}
